{extend name="layout/base" /}
<!-- 标题 -->
{block name="title"}{$column['column_name']}{/block}
<!-- CSS -->
{block name="css"}{/block}
<!-- 具体内容 -->
{block name="content"}
<h2 class="header-dividing">{$column['column_name']} <small>{$column['column_enname']}</small></h2>
<div class="navbar navbar-default navbar-content">
    <div class="collapse navbar-collapse">
        <ul class="nav navbar-nav">
            <li><a href="{:url('@admin/wsarticle/create', $urlparam)}"> <i class="icon icon-plus"></i> 添加内容</a></li>
            {if($column['column_cate'])}
            <li><a href="{:url('@admin/wscate', $urlparam)}"> <i class="icon icon-branch"></i> 内容分类</a></li>
            {/if}
            <li><a href="{:url('@admin/wscolumn', $urlparam)}"> <i class="icon icon-lightbulb"></i> 栏目设置</a></li>
        </ul>
        <!-- 导航中的表单 -->
        <form class="navbar-form navbar-left" role="search" method="get" action="{:url('@admin/wsarticle')}">
            <input type="hidden" name="siteid" value="{$siteid}">
            <input type="hidden" name="columnid" value="{$columnid}">
            {if($column['column_cate'])}
            <select class="form-control" name="cateid">
                <option value="">请选择分类</option>
                {volist name="wscate" id="vo"}
                <option value="{$vo['wscate_id']}" {$vo['wscate_id']!=$cateid?:'selected'}>{:dp_prefix($vo['wscate_path'])} {$vo['wscate_name']}</option>
                {/volist}
            </select>
            {/if}
            <input type="text" class="form-control" name="keywords" placeholder="搜索" value="{$keywords}">
            <button type="submit" class="btn btn-default">搜索</button>
            <button type="button" class="btn" data-remote="{:url('@admin/help/main')}" data-show-header="false" data-toggle="modal">帮助</button>
        </form>
    </div>
</div>

<div class="panel">
    <table class="table datatable table-fixed" data-checkable="true" data-fixed-right-width="240" data-check-by-click-row="false">
        <thead>
            <tr>
                <th data-width="50" width="50" class="text-center">ID</th>
                <th>标题</th>
                {if($column['column_cate'])}<th data-width="210" width="210" class="flex-col">分类</th>{/if}
                <th data-width="150" width="150" class="flex-col">发布时间</th>
                <th data-width="80" width="80" class="flex-col text-center">访问量</th>
                <th data-width="80" width="80" class="flex-col text-center">推荐</th>
                <th data-width="80" width="80" class="flex-col text-center">首页</th>
                <th data-width="80" width="80" class="text-center">修改</th>
                <th data-width="80" width="80" class="text-center">复制</th>
                <th data-width="80" width="80" class="text-center">删除</th>
            </tr>
        </thead>
        <tbody>
            {volist name="list" id="vo"}
            <tr data-id="{$vo['wsarticle_id']}">
                <td class="text-center">{$vo['wsarticle_id']}</td>
                <td>
                    {if (getimg($vo['wsarticle_image'])!='')}
                        <a href="{:getimg($vo['wsarticle_image'])}" class="lightbox-toggle"><i class="fe fe-picture-square f20"></i></a> 
                    {else /}
                        <i class="fe fe-share f20"></i> 
                    {/if}
                    <a href="{:url('@admin/wsarticle/edit', $urlparam.'&id='.$vo['wsarticle_id'])}" title="{$vo['wsarticle_title']}">{$vo['wsarticle_title']}</a>
                </td>
                {if($column['column_cate'])}<td>{:show_cate($vo['wsarticle_cateid'], $wscate)}</td>{/if}
                <td>{$vo['wsarticle_create_time']}</td>
                <td class="text-center">{$vo['wsarticle_views']}</td>
                <td class="text-center">{$vo['wsarticle_recommend_html']|raw}</td>
                <td class="text-center">{$vo['wsarticle_home_html']|raw}</td>
                <td class="text-center"><a href="{:url('@admin/wsarticle/edit', $urlparam.'&id='.$vo['wsarticle_id'])}">修改</a></td>
                <td class="text-center"><a class="copy" data-url="{:url('@admin/wsarticle/copy', 'id='.$vo['wsarticle_id'])}" >复制</a></td>
                <td class="text-center"><a class="delete" data-url="{:url('@admin/wsarticle/delete','id='.$vo['wsarticle_id'])}">删除</a></td>
            </tr>
            {/volist}
        </tbody>
    </table>
    {empty name="list"}
    <div class="mb20 mt20 text-center">
        {if ($keywords!='' || $cateid != '')}
            未搜索到 “{$keywords}” 相关的内容 &nbsp; <a href="{:url('@admin/wsarticle', $urlparam)}">查看全部内容</a>
        {else /}
            暂未添加内容
        {/if}
    </div>
    {/empty}
    {notempty name="list"}
    <div class="mb10 ml10">
        <button class="btn btn-danger check-delete" type="button" data-url="{:url('@admin/wsarticle/delete')}">删除内容</button>
        {if($column['column_cate'])}
            <div class="btn-group dropup">
                <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
                    设置分类 <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" role="menu" style="max-height: 300px; overflow: auto;">
                    {volist name="wscate" id="vo"}
                    <li><a class="wsarticle-cate" data-cateid="{$vo['wscate_id']}">{:dp_prefix($vo['wscate_path'])}{$vo['wscate_name']}</a></li>
                    {/volist}
                </ul>
            </div>
        {/if}        
        <div class="btn-group dropup">
            <button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown">
                设置属性 <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" role="menu">
                <li><a class="wsarticle-attr" data-attr="home" data-value="1">首页内容</a></li>
                <li><a class="wsarticle-attr" data-attr="home" data-value="0">取消首页</a></li>
                <li class="divider"></li>
                <li><a class="wsarticle-attr" data-attr="recommend" data-value="1">推荐内容</a></li>
                <li><a class="wsarticle-attr" data-attr="recommend" data-value="0">取消推荐</a></li>
            </ul>
        </div>
    </div>
    {/notempty}
</div>

<div class="text-center mb20">
    {$list|raw}
</div>
{/block}

<!-- JS -->
{block name="js"}
    {load href="/static/lib/jquery/jquery.form.js"}
    {load href="/static/lib/validator/validator.min.js"}
{/block}
{block name="jscode"}
<script type="text/javascript">
$(document).ready(function() {
    $(".wsarticle-cate").click(function(e) {
        var cateid = $(this).data('cateid');
        var myDatatable = $('table.datatable').data('zui.datatable');
        // 获取行选中数据
        var checksStatus = myDatatable.checks;
        if (checksStatus == undefined) {
            return sxj.msg_error('提示：未选择内容！');
        }
        sxj.ajax_put("{:url('@admin/wsarticle/cate')}", { 
            id: checksStatus.checks.toString(), cateid: cateid 
        });
    });

    $(".wsarticle-attr").click(function(event) {
        var attr = $(this).data('attr');
        var value = $(this).data('value');
        var myDatatable = $('table.datatable').data('zui.datatable');
        // 获取行选中数据
        var checksStatus = myDatatable.checks;
        if (checksStatus == undefined) {
            return sxj.msg_error('提示：未选择内容！');
        }
        sxj.ajax_put("{:url('@admin/wsarticle/attr')}", { id: checksStatus.checks.toString(), attr: attr, value: value });
    });

    // 图片预览
    $('a.lightbox-toggle').lightbox({image: $(this).attr('href')});
});
</script>
{/block}